#include "SceneGraphHandler.h"

#ifdef __linux__
	string path = "Gelaende/Fonts/Vera.ttf";
#elif _WIN32
	string path = "Fonts\\Vera.ttf";
#endif

void SceneGraphHandler::setEyeX(double eye){ eyeX = eye; setCameraViewMatrixAsLookAt(); }

void SceneGraphHandler::setEyeY(double eye){ eyeY = eye; setCameraViewMatrixAsLookAt(); }

void SceneGraphHandler::setEyeZ(double eye){ eyeZ = eye; setCameraViewMatrixAsLookAt(); }

void SceneGraphHandler::setCenterX(double center){ centerX = center; setCameraViewMatrixAsLookAt(); }

void SceneGraphHandler::setCenterY(double center){ centerY = center; setCameraViewMatrixAsLookAt(); }

void SceneGraphHandler::setCenterZ(double center){ centerZ = center; setCameraViewMatrixAsLookAt(); }

void SceneGraphHandler::setCameraViewMatrixAsLookAt(){
	
	osg::Vec3 eye(eyeX,eyeY,eyeZ);
    osg::Vec3 center(centerX, centerY, centerZ);
    osg::Vec3 up(0.0,0.0,1.0);

	viewer.getCamera()->setViewMatrixAsLookAt(eye,center,up);
}

double SceneGraphHandler::getEyeX(){ return eyeX; }
double SceneGraphHandler::getEyeY(){ return eyeY; }
double SceneGraphHandler::getEyeZ(){ return eyeZ; }
double SceneGraphHandler::getCenterX(){ return centerX; }
double SceneGraphHandler::getCenterY(){ return centerY; }
double SceneGraphHandler::getCenterZ(){ return centerZ; }

Hud SceneGraphHandler::getHud(){
	return hud;
}

void SceneGraphHandler::addTextBox(TextBox& t) {
	hud.addTextBox(t);
}

void SceneGraphHandler::erstelleTextBoxen(){
	/** Key Switch Camera Manipulator Text **/
	cameraManipulatorText->setPosition(osg::Vec3d(10, 10, 0));
    cameraManipulatorText->setFont(path);
    cameraManipulatorText->setTextSize(14);
	cameraManipulatorText->setColor(osg::Vec4d(255,255,255,1));
	cameraManipulatorText->setText( "Eigener Manipulatoar");

	addTextBox(*cameraManipulatorText);

	/** Legende **/
	legende->setPosition(osg::Vec3d(570, 580, 0));
    legende->setFont(path);
    legende->setTextSize(18);
	legende->setColor(osg::Vec4d(255,255,255,1));
	legende->setText( "-----L e g e n d e -----");

	legendeBewegen->setPosition(osg::Vec3d(530, 550, 0));
    legendeBewegen->setFont(path);
    legendeBewegen->setTextSize(14);
	legendeBewegen->setColor(osg::Vec4d(255,255,255,1));
	legendeBewegen->setText( "--- Bewegen --- \n\n   W -> Vor \n   S -> Zurueck \n   A -> Links \n   D -> Rechts \n   Q -> Hoch \n   E -> Runter");

	legendeSchauen->setPosition(osg::Vec3d(670, 550, 0));
    legendeSchauen->setFont(path);
    legendeSchauen->setTextSize(14);
	legendeSchauen->setColor(osg::Vec4d(255,255,255,1));
	legendeSchauen->setText( "----- Schauen ----- \n\n   P -> Hinein \n   K -> Zurueck \n   J -> Links \n   L -> Rechts \n   U -> Hoch \n   O -> Runter");

	legendeManipulator->setPosition(Vec3d(550, 430, 0));
    legendeManipulator->setFont(path);
    legendeManipulator->setTextSize(14);
	legendeManipulator->setColor(Vec4d(255,255,255,1));
	legendeManipulator->setText( "----- Kamera-Manipulatoren -----\n\n         1 -> Eigener ( M druecken :-) )\n         2 -> Trackball \n         3 -> First Person \n         4 -> Drive \n         5 -> Terrain \n         6 -> Flight \n         7 -> Node Tracker \n         8 -> U-F-O \n         9 -> Spherical \n         0 -> Multi Touch Trackball \n         P -> Orbit \n\n         SPACE -> Home-Position \n         Y -> Manipulator Info \n         C -> Nebel \n         S -> Analyse FPS");

	legendeLicht->setPosition(osg::Vec3d(610, 160, 0));
    legendeLicht->setFont(path);
    legendeLicht->setTextSize(14);
	legendeLicht->setColor(osg::Vec4d(255,255,255,1));
	legendeLicht->setText( "     ----- Licht ----- \n\nV -> Sonne \\ Mond \n R -> alle Hauslichter\n T -> Wohnzimmer \n Z -> Kueche\n F -> Schlafzimmer\n G -> Flur\n H -> Bad");
	
	/** Hilfe **/
	helpText->setPosition(osg::Vec3d(680, 10, 0));
    helpText->setFont(path);
    helpText->setTextSize(14);
	helpText->setColor(osg::Vec4d(255,255,255,1));
	helpText->setText( "Hilfe -> X-Taste");

	muhh->setPosition(osg::Vec3d(180, 30, 0));
    muhh->setFont("./Fonts/Vera.ttf");
    muhh->setTextSize(40);
	muhh->setColor(osg::Vec4d(255,0,0,1));
	muhh->setText( "M U H H H ..... Muhhh !!!!!");

	addTextBox(*helpText);
}
